<?php

namespace App\Service\Index\v1_2_0;

use App\Model\CallBase;
use App\Model\VoiceCall;
use App\Service\BaseService;

/**
 * 呼叫信息
 */
class CallingBaseService extends BaseService
{
    function getCallFrom($callFrom = 0)
    {
        switch ($callFrom) {
            case 1:
                return '随心聊';
            case 2:
                return '天天福利';
            case 3:
                return '速配';
            case 4:
                return '视频约会';
            case 10:
                return '特惠视频';
            default:
                return '常规';
        }
        return '未知';
    }

    function callTips($type = 'video')
    {
        return [
            '本平台提倡绿色文明交友',
            '严禁出现色情，诈骗或诱导',
            '第三方交易行为，严禁谈论',
            '涉政等政治话题，系统已接',
            '入自动检测，一经发现立即',
            '封号并上报有关部门。'
        ];
    }

    /**
     * 显示金币收益（消费）文字
     */
    function getCoinText(
        $coinSetting = 0.0,
        $paramCallFrom = 0,
        $isCaller = 1,
        $callType = VoiceCall::CALL_TYPE,
        $callFrom = 1,
        $callMark = 1
    ) {
        $callTypeText = $callType == VoiceCall::CALL_TYPE ? '语音' : '视频';
        $userTip = "{$callTypeText}通话 {$coinSetting}金币/分钟";
        $hostTip = $this->getCallFrom($paramCallFrom) . "通话 {$coinSetting}金币/分钟";
        //主播呼叫显示收益
        if (CallBase::FROM_HOST_CALL == $callFrom) $coinText = $isCaller ? $hostTip : $userTip;
        else $coinText = $isCaller ? $userTip : $hostTip;
        //呼叫方的天天福利，显示“免费”
        if (($paramCallFrom == 2 && $isCaller) || $callMark == 2) $coinText = '免费';

        if (($paramCallFrom == 4 && $isCaller) || $callMark == 2) $coinText = $this->getCallFrom($paramCallFrom)."通话 {$coinSetting}金币/2分钟";
        if (($paramCallFrom == 4 && !$isCaller) || $callMark == 2) $coinText = '免费';

        return $coinText;
    }
}
